home *** CD-ROM | disk | FTP | other *** search
- /* Search Altavista thru Amirc or CLI. © 2000 by PurpleT. Requires HttpResume */
- /* $VER V1.1 Bug reports? suggestions? Mailto: purplet@dingoblue.net.au */
-
- /* P R E F S A R E A */
-
-
- MaxHits = 3
-
- /* Info Fields */
-
- ShowDescription = "Y" /* [ Y/N ] */
- ShowFileURL = "Y" /* [ Y/N ] */
-
- SeparateOutput = "N" /* [ Y/N ] */
- DeleteTempAfter = "Y" /* [ Y/N ] */
-
- AVSTempFile = "Ram:AVSTemp.html"
- HttpResumePath = "C:HttpResume"
-
- /* E N D P R E F S */
-
-
-
-
- /* Don't Edit Anything Below This Point!! */
-
- Options results
- parse arg SearchString;NL='0a'x;ES= d2c(27);Bold = d2c(2);TC = 1
-
- CheckIt = getclip(AVSearch)
-
- If CheckIt = "RUN" then DO
- techo("Search already in progress. Wait for current search to finish.")
- Exit
- End
-
- Setclip(AVSearch,"RUN")
-
- If SearchString = "" then DO
- Techo("Usage: /RX AVSearch <Search Keywords>")
- Call EndProg
- End
-
- If exists(httpresumepath) = 0 then DO
- Techo("Error: You need HttpResume to use this! :)")
- Call EndProg
- End
- If MaxHits > 10 then MaxHits = 10
- If MaxHits < 1 then MaxHits = 1
-
- Techo("Searching for "bold""SearchString""Bold" on AltaVista, MaxHits = "bold""MaxHits""bold", Please wait...")
-
- SearchString2 = Translate(SearchString,"+"," ")
- If Exists(AVSTempFile) = 1 then Address command "delete >nil: "AVSTempFile
- address command httpresumepath' url = "http://www.altavista.com/cgi-bin/query?pg=q&sc=on&hl=on&act=2006&par=0&q='SearchString2'&search.x=21&search.y=6&kl=XX&stype=stext" OF = 'AVSTempFile' Referer = "http://www.altavista.com" >nil:'
-
- If Exists(AVSTempFile) = 0 then DO
- Techo("Error: File not found - "AVSTempFile)
- Call EndProg
- End
-
- Open(File1,AVSTempFile,"R")
-
- call time(R)
-
- Do i = 1 to MaxHits
- HLine = readln(file1)
- Do until HLine = "<b class=txt2>"i".</b>"
- HLine = ReadLn(File1)
- If Find(HLine,"found no document matching your") ~=0 then DO
- Techo("No matches found for "Bold""SearchString)
- Call EndProg
- End
- If upper(HLine) = "</HTML>" then DO
- Call EndProg
- End
- End
- XT=Readln(File1);XT=Readln(File1)
-
- ULine = Word(Translate(SubStr(Readln(File1),13),"",""">"),1)
- techo(bold""i". "Bold""ULine)
- XT=Readln(File1);XT=Readln(File1)
-
- Description = ReadLn(File1)
- XT=ReadLn(File1);XT=ReadLn(File1)
-
- FileURL = ReadLn(File1) /* ;FileURL = SubStr(Left(FileURL,Length(FileURL)-11),4) */
-
- Desc = Description
-
- /* Begin Snorslex's Sheer Coding Brilliance ;-) */
-
- amirc_bold='02'x
- amirc_uline='1F'x
- cr=''x
- Tags ="<B> </B> <U> </U> <BR>"
- NewTags ="amirc_bold amirc_bold amirc_uline amirc_uline cr"
-
- DO UNTIL Tags=''
- PARSE VAR Tags Tag Tags
- PARSE VAR NewTags NewTag NewTags
- CALL TagCleanup(UPPER(Tag),NewTag)
- END
-
- /* End Snorslex's Sheer Coding Brilliance ;-) */
-
- Description = Desc
-
- If upper(ShowDescription) = "Y" then Techo(Bold" "Bold""Description)
- If upper(ShowFileURL) = "Y" then Techo(Bold" "Bold""FileURL)
- If Upper(SeparateOutput) = "Y" then Techo(Bold""Bold)
- End
- Call EndProg
- Exit
-
- EndProg:
- Close(File1)
- Techo(Bold"Search Complete")
- SetClip(AVSearch,"")
- If Upper(DeleteTempAfter) = "Y" then DO
- address command 'C:Delete >nil: 'AVSTempFile
- End
- Exit
- Return
-
- Techo:
- parse arg EchoString
- "ECHO P="d2c(27)"b«AVSearch» C="TC" "EchoString
- say EchoString
- Return 0
-
- /* Begin Snorslex's Sheer Coding Brilliance (Part II) :) */
-
- TagCleanup:
- curr_tag=ARG(1)
- curr_newtag=ARG(2)
- DO FOREVER
- posi=POS(curr_tag,UPPER(desc))
- IF posi>0 THEN DO
- desc=LEFT(desc,posi-1)||VALUE(curr_newtag)||SUBSTR(desc,posi+LENGTH(curr_tag),LENGTH(desc)-posi)
- END
- ELSE LEAVE
- END
- RETURN
-
- /* End Snor... you get the picture :) */
-